

import java.util.Random;

public class MakeQuestions {
    private Random  r1 = new Random();
    private Operand opd = new Operand();
    private String operator;
    private String expr;

    public MakeQuestions(){

    }
    //生成题目
    public String getExper(int i){
        //用循环的方法来获取多运算符
        expr = opd.getOp1() + getOperator();
        for (int j = 0; j < i-1; j++) {
            String s = opd.getOp1() + getOperator();
            expr += s;
        }
        expr = expr + opd.getOp2();
        return expr;
    }

    //随机获取运算符
    private String getOperator(){
        int i = r1.nextInt(4);
        if (i == 0){
            operator = " + ";
        }
        else if (i == 1){
            operator = " - ";
        }
        else if (i == 2){
            operator = " * ";
        }
        else if (i == 3){
            operator = " ÷ ";
        }
        return operator;
    }
}